home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
csmplr.zip
/
CSMPLR.NEW
< prev
Wrap
Text File
|
1990-06-18
|
28KB
|
1,173 lines
/* 1: 2.1.1.2 Backslash-splicing */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
i\
n\
t\
i = 3;
if (i == 3)
printf("success\n");
return 0;
}
/* 2: 2.1.1.2 Phases of translation */
/* #define NOTDEFINED 1 */
??=include/* SPACE */<stddef.h>
#\
i\
f\
!\
defined(NOTDEFINED)
#define UI unsigned in??/
t
#define/* SPACE */PCHAR(/*SPACE*/x/*SPACE*/)/* SPACE */char x/*SPACE*/??(??)
#endif
UI/* SPACE */Ui/* SPACE */=/* SPACE */'\
\n' ;
PCHAR(Pc) = "string1??/
#\
"\
"string2" ;
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (Ui == '\n' && Pc[8] == 's')
printf("success\n");
return 0;
}
/* 3: 2.2.1.1 Trigraphs */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
??<
int i = 3;
if (i == 3)
printf("success\n");
??>
return 0;
}
/* 4: 2.2.4.2 <float.h> -- e.g., DBL_DIG >= 10 [87/03] */
#include <float.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (DBL_DIG >= 10)
printf("success\n");
return 0;
}
/* 5: 2.2.4.2 <limits.h> -- e.g., has MB_LEN_MAX [87/12] */
#include <limits.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (CHAR_BIT >= 8 && INT_MIN <= -32767 && MB_LEN_MAX >= 1)
printf("success\n");
return 0;
}
/* 6: 3.1.2 Internal identifier significance at least 31 characters */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
int a23456789012345678901234567890a = 3;
int a23456789012345678901234567890b = 4;
if (a23456789012345678901234567890a == 3 &&
a23456789012345678901234567890b == 4)
printf("success\n");
return 0;
}
/* 7: 3.1.2.2 Scope rules: file, function, prototype, and block */
#include <stdio.h>
int x = 2; /* this x has file scope */
main()
{
int start = (printf("started\n"));
int f();
if (f() == 1)
printf("success\n");
return 0;
}
int f()
{
int c(int x); /* this x has prototype scope */
if (x != 2)
exit(2);
else
{
char x = 3; /* this x has block scope */
if (x != 3)
exit(3);
goto x;
exit(4);
}
x: /* this x has function scope */
return 1;
}
/* 8: 3.1.2.3 Name space rules: variables, labels, tags, and members */
#include <stdio.h>
#include <stdlib.h>
main()
{
int start = (printf("started\n"));
static struct x { int x; } x = {6};
goto x;
exit(0);
x:
if (x.x == 6) printf("success\n");
return 0;
}
/* 9: 3.1.2.3 Unique member name spaces */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
static struct a { char x; } a = {7};
static struct b { double x; } b = {8};
if (a.x == 7 && b.x == 8)
printf("success\n");
return 0;
}
/* 10: 3.1.2.5 long double (even if same size as double ) */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
long double x = 4.L;
if (x == 4L)
printf("success\n");
return 0;
}
/* 11: 3.1.2.5 all unsigned types */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
unsigned char uc = 1;
unsigned short us = 2;
unsigned int ui = 4;
unsigned long ul = 7;
if (ul - ui - us - uc == 0)
printf("success\n");
return 0;
}
/* 12: 3.1.2.5 signed char */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
signed char sc = -1;
if (8 * sc == -8)
printf("success\n");
return 0;
}
/* 13: 3.1.2.6 Type-compatibility rules [87/12] */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
const int *f();
if (*f(&start) == start)
printf("success\n");
return 0;
}
int signed const *f();
signed int const *f(int *);
int const *f(int *pi)
{
return pi;
}
/* 14: 3.1.3.2 constants: U, L, unsignedness rules */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (-1 < 1u)
;
else if (1UL != 1ul)
;
else
printf("success\n");
return 0;
}
/* 15: 3.1.3.4 character constants with more than one char */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
int c = 'abcd';
printf("success\n");
return 0;
}
/* 16: 3.1.3.4 '\xFF' */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if ('\xFF' == (char)0xFF)
printf("success\n");
return 0;
}
/* 17: 3.1.3.4 '\a' '\v' */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if ('\a' != 'a' && '\v' != 'v')
printf("success\n");
return 0;
}
/* 18: 3.1.3.4 Wide-characters: L'x', L"x", wc*, mb*, wchar_t [87/12] */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
int f();
if (f() == 2)
printf("success\n");
return 0;
}
#include <stdlib.h>
int f()
{
wchar_t wc = L'\0';
wchar_t wcs[] = L"";
char s[2];
if (wc == 0 && wctomb(s, wc) == 1)
return 2;
return 0;
}
/* 19: 3.1.5 "Old-style" assignment-operators are gone */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
short n = 3;
short m = 2;
n=-m;
if (n == -2)
printf("success\n");
return 0;
}
/* 20: 3.2.1.1 "Value-preserving" integer conversion rules */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (sizeof(int) > sizeof(char))
{
unsigned char uc1 = 1;
unsigned char uc2 = 2;
if (uc1 - uc2 < 0)
printf("success\n");
}
else
printf("success\n"); /* conforming, but weird */
return 0;
}
/* 21: 3.2.1.5 Expressions with float operands have float type */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
float x, y;
if (sizeof(x + y) == sizeof(float))
printf("success\n");
return 0;
}
/* 22: 3.2.2.1 Address-of on array and function */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
char a[10];
if (sizeof(*&a) == 10 && main == &main)
printf("success\n");
return 0;
}
/* 23: 3.2.2.1 Call-through-pointer (*pkg.fn)() may be written pkg.fn() */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
int f();
int (*pf)() = f;
if (pf() == 5)
printf("success\n");
return 0;
}
int f()
{
return 5;
}
/* 24: 3.2.2.2 OK to cast void to void [87/09] */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
void f();
(void)f();
return 0;
}
void f()
{
printf("success\n");
}
/* 25: 3.2.2.3 Generic pointers: void * */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
void *gp;
float x, y;
gp = &x;
if (gp == &x && gp != &y)
printf("success\n");
return 0;
}
/* 26: 3.3.2.2 prototype-with-default-sizes is compatible with no-prototype */
#include <stdio.h>
int f();
int f(int);
main()
{
int start = (printf("started\n"));
if (f(0) == 2)
printf("success\n");
return 0;
}
int f(int i)
{
return i + 2;
}
/* 27: 3.3.2.2 Calling a prototyped function causes conversion (as if by ass't) */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
double f(double);
if (f(2) == -2.0)
printf("success\n");
return 0;
}
double f(double x)
{
return -x;
}
/* 28: 3.3.3.3 Unary plus */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
int i = 3;
if (+i == 3)
printf("success\n");
return 0;
}
/* 29: 3.3.3.4 sizeof applies to any rvalue expression */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
int i;
if (sizeof(i+1) == sizeof(int))
printf("success\n");
return 0;
}
/* 30: 3.3.16.1 Structure assignment, return, and argument-passing */
#include <stdio.h>
static struct x { int i; } a = {1};
main()
{
int start = (printf("started\n"));
struct x b;
struct x c;
struct x f();
b = a;
c = f(b);
if (c.i == 1)
printf("success\n");
return 0;
}
struct x f(v)
struct x v;
{
return v;
}
/* 31: 3.5.2.2 enum and tag-scope rules [87/03] */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
enum b { bm2=-2, b0=bm2+2, b1, b2 } b = b2;
switch (b)
{
case b2:
printf("success\n");
default:
;
}
return 0;
}
/* 32: 3.5.2.3 struct sb; introduces a new scope */
#include <stdio.h>
struct sb { double x; } bx = { 9.9 };
main()
{
int start = (printf("started\n"));
struct sb;
struct sa { struct sb *pb; int i; } a;
struct sb { struct sa *pa; int i; } b;
b.i = 13;
a.pb = &b;
if (a.pb->i == 13)
printf("success\n");
return 0;
}
/* 33: 3.5.3 const is independent qualifier of e.g. struct type */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
const struct sa { int i; } csa;
const struct sa *pcsa = &csa;
struct sa sa2;
sa2.i = 9;
if (sa2.i == 9 && pcsa == &csa)
printf("success\n");
return 0;
}
/* 34: 3.5.3 volatile preserves auto values modified after setjmp */
#include <stdio.h>
#include <setjmp.h>
jmp_buf env;
main()
{
int start = (printf("started\n"));
volatile int n = 2;
if (setjmp(env) == 0)
{
n = 6;
longjmp(env, 1);
}
else
{
if (n == 6)
printf("success\n");
}
return 0;
}
/* 35: 3.5.4 ellipsis -- e.g. int printf(const char *, ...); */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
int printf(const char *fmt, ...);
printf("success\n");
return 0;
}
/* 36: 3.5.4 prototypes (for declarations) */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
int f(int);
if (f(0) == 4)
printf("success\n");
return 0;
}
int f(i)
int i;
{
return 4;
}
/* 37: 3.5.4 prototypes (for "new-style" definitions) */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
short f(short);
if (f(0) == 4)
printf("success\n");
return 0;
}
short f(short i)
{
return 4;
}
/* 38: 3.5.7 Elided-braces rules (as in K&R, not in PCC) */
#include <stdio.h>
struct sa { int a[3]; int b; } asa[2] = { {1}, 2 }; /* from Std */
main()
{
int start = (printf("started\n"));
if (asa[0].a[0] == 1 && asa[1].a[0] == 2)
printf("success\n");
return 0;
}
/* 39: 3.5.7 auto aggregate initializers */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
char msg[20] = {"success\n"};
printf(msg);
return 0;
}
/* 40: 3.5.7 union initializers (via first member) */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
union { char *msg; double d; } md = {"success\n"};
printf(md.msg);
return 0;
}
/* 41: 3.6.4.2 long-size switch labels */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
long lnum = 2;
switch (lnum)
{
default:
exit(3);
case 2L:
printf("success\n");
}
return 0;
}
/* 42: 3.7.2 Tentative definition for static */
#include <stdio.h>
static struct sa { struct sb *pb; int i; } a;
static struct sb { struct sa *pa; int i; } b = { &a, 13 };
static struct sa a = { &b, 11 };
main()
{
int start = (printf("started\n"));
if (a.i == 11 && b.pa->pb->i == 13)
printf("success\n");
return 0;
}
/* 43: 3.8.1 #if defined, #elif */
#define DEF 1
#include <stdio.h>
main()
{
int start = (printf("started\n"));
#ifdef NODEF
exit(3);
#elif defined(DEF)
printf("success\n");
#endif
return 0;
}
/* 44: 3.8.1 no syntax-checking of skipped groups */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
#if NODEF
L'x' 1.2.3.4.E--xx @$*** JUNK (((
#else
printf("success\n");
#endif
return 0;
}
/* 45: 3.8.2 #include macro-name */
#define STDIO <stdio.h>
#include STDIO
main()
{
int start = (printf("started\n"));
char *p = NULL;
printf("success\n");
return 0;
}
/* 46: 3.8.3 "hiding" of macro names */
#include <stdio.h>
int f(a, b, c)
int a, b, c;
{
return c+4;
}
#define f(a, b) f(a, b, 0)
main()
{
int start = (printf("started\n"));
int a=1, b=2;
if (f(a, b) == 4)
printf("success\n");
return 0;
}
/* 47: 3.8.3 benign re-definition allowed */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
#define A 1 + 1
#define A 1 + 1
#define A 1 /**/ + /**/ 1
if (A == 2)
printf("success\n");
return 0;
}
/* 48: 3.8.3 Preprocessor catenation and string-izing */
#include <stdio.h>
#define STR(a) NXSTR(a)
#define NXSTR(a) #a
#define CAT(a, b) NXCAT(a, b)
#define NXCAT(a, b) a ## b
#define A 1
#define B 2
#define AB 5
main()
{
int start = (printf("started\n"));
if (STR(A)[0] == '1' &&
NXSTR(B)[0] == 'B' &&
CAT(A, B) == 12 &&
NXCAT(A, B) == 5)
printf("success\n");
return 0;
}
/* 49: 3.8.5 New preprocessor directive #pragma */
#pragma IGNORE THIS NON-EXISTENT PRAGMA
#include <stdio.h>
main()
{
int start = (printf("started\n"));
printf("success\n");
return 0;
}
/* 50: 3.8.8 Predefined macro names */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (__DATE__[7] == '1' &&
__TIME__[2] == ':' &&
__FILE__[0] != '\0' &&
__LINE__ > 6 &&
__STDC__ == 1)
printf("success\n");
return 0;
}
/* 51: 4.1.3 <errno.h> [87/03] */
#include <errno.h>
#include <stdio.h>
main()
{
int errno_init = errno;
int start = (printf("started\n"));
if (errno_init == 0)
printf("success\n");
return 0;
}
/* 52: 4.1.5 <stddef.h> -- e.g. offsetof on nested struct member [88/04] */
#include <stddef.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
struct x { struct y { char c; } y; int z; } x;
if (offsetof(struct x, y.c) == 0)
printf("success\n");
return 0;
}
/* 53: 4.2 <assert.h> is a void expression [87/12] */
#include <assert.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
0, assert(1 == 1);
printf("success\n");
return 0;
}
/* 54: 4.3 <ctype.h> */
#include <ctype.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (isalpha('a'))
printf("success\n");
return 0;
}
/* 55: 4.4 <locale.h> -- e.g., initial locale is "C" */
#include <locale.h>
#include <string.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
char initial_locale[100];
strncpy(initial_locale, setlocale(LC_ALL, NULL), 100);
setlocale(LC_ALL, "C");
if (LC_ALL != LC_COLLATE &&
strncmp(setlocale(LC_ALL, NULL), initial_locale, 100) == 0)
printf("success\n");
return 0;
}
/* 56: 4.4 localeconv, LC_CURRENCY, negative_sign [88/04] */
#include <locale.h>
#include <stddef.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
struct lconv *plc;
plc = localeconv();
if (plc->negative_sign[0] == '\0') /* default "C" value is "" */
printf("success\n");
return 0;
}
/* 57: 4.5 <math.h> */
#include <math.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (HUGE_VAL != 0.0)
printf("success\n");
return 0;
}
/* 58: 4.5.1 Math library sets errno when required */
#include <math.h>
#include <errno.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
asin(10.);
if (errno == EDOM)
printf("success\n");
return 0;
}
/* 59: 4.6 <setjmp.h> */
#include <setjmp.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
jmp_buf buf;
if (setjmp(buf) == 0)
printf("success\n");
return 0;
}
/* 60: 4.7 <signal.h> */
#include <signal.h>
#include <stdio.h>
void func(int sig)
{
if (sig == SIGINT)
printf("success\n");
}
main()
{
int start = (printf("started\n"));
signal(SIGINT, func);
raise(SIGINT);
return 0;
}
/* 61: 4.8 <stdarg.h> */
#include <stdarg.h>
#include <stdio.h>
func(int nargs, ...)
{
va_list ap;
double d;
int i;
va_start(ap, nargs);
d = va_arg(ap, double);
if (d == 1.1 && va_arg(ap, int) == 7)
printf("success\n");
va_end(ap);
}
main()
{
int start = (printf("started\n"));
func(2, 1.1, 7);
return 0;
}
/* 62: 4.9 <stdio.h> -- e.g., OK to include more than once */
#include <stdio.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (BUFSIZ >= 256 && TMP_MAX >= 25)
printf("success\n");
return 0;
}
/* 63: 4.9.1 In <stdio.h>: FOPEN_MAX and FILENAME_MAX [87/12] */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (FOPEN_MAX > 0 && FILENAME_MAX > 0)
printf("success\n");
return 0;
}
/* 64: 4.9.2 Stream and file semantics: opening, seeking, text-binary */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
char name[1000];
FILE *f;
tmpnam(name);
f = fopen(name, "w+b");
fputc(1, f);
fputc(2, f);
rewind(f);
if (fgetc(f) == 1 && fgetc(f) == 2)
printf("success\n");
return 0;
}
/* 65: 4.9.4 remove, rename */
#include <stdio.h>
char old[1000];
char new[1000];
main()
{
int start = (printf("started\n"));
FILE *f;
tmpnam(old);
tmpnam(new);
f = fopen(old, "w");
fputc('a', f);
fclose(f);
rename(old, new);
if (fopen(old, "r") == NULL)
printf("success\n");
remove(new);
return 0;
}
/* 66: 4.9.6 full printf/scanf to new exact spec */
#include <stdio.h>
main()
{
int start = (printf("started\n"));
char buf[10];
union { struct { float f; char c; } s; double d; } u;
u.s.c = 'a';
sscanf("123.", "%E", &u.s.f);
sprintf(buf, "%.0d", 0);
if (u.s.f == 123. && u.s.c == 'a' && buf[0] == '\0')
printf("success\n");
return 0;
}
/* 67: 4.9.6 scanf and ungetc push-back independently [87/12] */
#include <stdio.h>
char name[1000];
main()
{
int start = (printf("started\n"));
FILE *f;
int i, j;
tmpnam(name);
f = fopen(name, "w+");
fprintf(f, "123 456\n");
rewind(f);
fscanf(f, "%d", &i);
ungetc('9', f);
fscanf(f, "%d", &j);
if (i == 123 && j == 9)
printf("success\n");
fclose(f);
remove(name);
return 0;
}
/* 68: 4.9.6 v*printf, v*scanf */
#include <stdarg.h>
#include <stdio.h>
void print(char *s, char *format, ...)
{
va_list args;
va_start(args, format);
vsprintf(s, format, args);
va_end(args);
}
main()
{
int start = (printf("started\n"));
char buff[10];
print(buff, "%.2d %.2d %.2d", 1, 2, 3);
if (strcmp(buff, "01 02 03") == 0)
printf("success\n");
return 0;
}
/* 69: 4.9.9 fsetpos fgetpos (and fpos_t ) */
#include <stdio.h>
char name[1000];
main()
{
int start = (printf("started\n"));
FILE *f;
fpos_t pos;
char buff[16];
tmpnam(name);
f = fopen(name, "w+");
fputs("first line\n", f);
fgetpos(f, &pos);
fputs("second line\n", f);
fputs("third line\n", f);
fsetpos(f, &pos);
fgets(buff, 16, f);
if (strcmp(buff, "second line\n") == 0)
printf("success\n");
fclose(f);
remove(name);
return 0;
}
/* 70: 4.10 <stdlib.h> -- e.g. has size_t [87/12] */
#include <stdlib.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
size_t n = 2;
if (n == 2)
printf("success\n");
return 0;
}
/* 71: 4.10.1 strtol, strtoul, strtod [87/12] */
#include <stdlib.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
unsigned long ul;
char *p;
ul = strtoul("+0x010Y", &p, 0);
if (ul == 16L && *p == 'Y')
printf("success\n");
return 0;
}
/* 72: 4.10.4 system, atexit, getenv, EXIT_SUCCESS, EXIT_FAILURE [86/12] */
#include <stdlib.h>
#include <stdio.h>
void func()
{
if (EXIT_SUCCESS != EXIT_FAILURE)
printf("success\n");
}
main()
{
int start = (printf("started\n"));
char *p = 0;
system("echo spawned >junk");
atexit(func);
p = getenv("");
return 0;
}
/* 73: 4.10.6 div ldiv */
#include <stdlib.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
div_t val;
ldiv_t lval;
val = div(-5, 3);
lval = ldiv(-5L, 3L);
if (val.quot == -1 && val.rem == -2 &&
lval.quot == -1L && lval.rem == -2L)
printf("success\n");
return 0;
}
/* 74: 4.11 <string.h> -- e.g. memset and strcmp */
#include <string.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
static char a[5] = "0123";
memset(a, 'x', 4);
if (strcmp(a, "xxxx") == 0)
printf("success\n");
return 0;
}
/* 75: 4.11.2 memmove, strstr [87/03] */
#include <string.h>
char *s = "0123456789";
#include <stdio.h>
main()
{
int start = (printf("started\n"));
char *p;
char q[11];
p = strstr("testXYZtest", "XYZ");
if (*p == 'X' && strstr(p, "") == p)
{
strcpy(q, s);
memmove(q, q+1, 9);
if (strcmp(q, "1234567899") ==0)
{
strcpy(q, s);
memmove(q+1, q, 9);
if (strcmp(q, "0012345678") == 0)
printf("success\n");
}
}
return 0;
}
/* 76: 4.11.6.2 strerror */
#include <string.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
if (strerror(0) != 0)
printf("success\n");
return 0;
}
/* 77: 4.12 <time.h> */
#include <time.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
char *p = NULL;
int i = (sizeof(clock_t) + sizeof(time_t));
if (i > 0)
printf("success\n");
return 0;
}
/* 78: 4.12.2.2 difftime */
#include <time.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
struct tm time1, time2;
time1.tm_isdst = time2.tm_isdst = 0;
time1.tm_year = time2.tm_year = 88;
time1.tm_mon = time2.tm_mon = 12;
time1.tm_mday = time2.tm_mday = 25;
time1.tm_hour = 7;
time2.tm_hour = 8;
time1.tm_min = time2.tm_min = 31;
time1.tm_sec = 13;
time2.tm_sec = 17;
if (difftime(mktime(&time2), mktime(&time1)) == 3604.0)
printf("success\n");
return 0;
}
/* 79: 4.12.3.5 strftime */
#include <time.h>
#include <string.h>
#include <stdio.h>
main()
{
int start = (printf("started\n"));
size_t nc;
struct tm time1;
char buff[500];
time1.tm_isdst = 0;
time1.tm_year = 88;
time1.tm_mon = 11; /* December */
time1.tm_mday = 25;
time1.tm_hour = 7;
time1.tm_min = 31;
time1.tm_sec = 13;
nc = strftime(buff, 500, "%B %d, 19%y, %I:%M %p", &time1);
if (nc == strlen(buff))
printf("success\n");
return 0;
}
/* THE REMAINING 22 ITEMS REQUIRE A FULL-SCALE VALIDATION SUITE ... */
/* 80: 2.* Full semantics: environment */
/* 81: 2.1.2.3 sequence points */
/* 82: 2.1.2.2 argv[0] is program-name or null-string */
/* 83: 2.2.4.1 translation-time capacity limits */
/* 84: 3.1.* All required diagnostics: Lexical elements */
/* 85: 3.1.* Full syntax and semantics: Lexical elements */
/* 86: 3.2.* All required diagnostics: Conversions */
/* 87: 3.2.* Full syntax and semantics: Conversions */
/* 88: 3.3.* Full syntax and semantics: Expressions */
/* 89: 3.3.* All required diagnostics: Expressions */
/* 90: 3.4.* Full syntax and semantics: Constant expressions */
/* 91: 3.4.* All required diagnostics: Constant expressions */
/* 92: 3.5.* All required diagnostics: Declarations */
/* 93: 3.5.* Full syntax and semantics: Declarations */
/* 94: 3.6.* All required diagnostics: Statements */
/* 95: 3.6.* Full syntax and semantics: Statements */
/* 96: 3.7.* All required diagnostics: External definitions */
/* 97: 3.7.* Full syntax and semantics: External definitions */
/* 98: 3.8.* All required diagnostics: Preprocessing directives */
/* 99: 3.8.* Full syntax and semantics: Preprocessing directives */
/* 100: 4.1.2 No reserved names in user name space */
/* 101: 4.1.2 No user names in standard headers */
/* THESE ITEMS ARE "THE 101 FEATURES" OF ANSI/ISO C. */
/* Items 1-79 can be sampled with this Plum Hall Validation Sampler. */
/* Items 80-101 require a full-scale Validation Suite. */
/* (Contact Plum Hall for information about the comprehensive tests */
/* embodied in the Plum Hall Validation Suite for C.) */
/* This "Sampler" is not intended for any formal certification or */
/* validation work; it is intended only to provide an overall */
/* estimate of how close a compiler is to the soon-to-be ANSI Standard. */
/* Copyright (c) 1988, Plum Hall Inc and Chiron Systems Inc. */
/* Permission is granted for reproduction and use of this "Sampler" */
/* provided that this notice is reproduced entirely. */
/* Tom Plum, Plum Hall Inc, 609-927-3770, uunet!plumhall!plum . */
/* Ralph Ryan, Chiron Systems Inc. */
/* With assistance from Don Gallagher and Scott Erlichman. ... */
/* REVISIONS: 88/12/22 */
/* Test 13: f(start) -> *f(&start) AND f(int) -> f(int *) */
/* Test 18: In function f (after line 249), add return 0; */
/* Test 72: On (now) line 988, change succeed to success */
/* Also, on line 994 change to "echo spawned >junk" */
/* Test 79: On line 1111, change month to 11 (zero-origin ouch) */
/* Tests 13 + 72 could have affected scoring; 18 + 79 are cosmetic */
/* REVISIONS: 89/03/03, to become "sampler.89a" */
/* Test 51: Capture errno before calling printf */
/* REVISIONS: 89/04/07, to become "sampler.89b" */
/* Test 55: Add #include <string.h> , for strncpy and strncmp */